<template>
    <div class="df jc-sb h100">
        <div class="pdfEmbed">
            <VuePdfEmbed :source="source" @loaded="onLoad" @loading-failed="loadingFailed" />
        </div>
        <div class="bg-fff right">
            <ProcessDetail :info="process" v-if="process" />
        </div>
    </div>
</template>

<script setup>
import VuePdfEmbed from 'vue-pdf-embed';
import ProcessDetail from '@/components/process-details/process-details.vue';
import { reactive, ref, onMounted } from 'vue';
import api from '@/apis/contract';
import { useRouter, useRoute } from 'vue-router';
import { errorTips, getDateTime } from '@/utils/utils';
import loadConfig from '@/config';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();

const $route = useRoute();
const snowflakeId = ref('');
const source = ref('');
onMounted(() => {
    source.value = $route.query.signContract;
    snowflakeId.value = $route.query.snowflakeId;
    getProcess(snowflakeId.value);
});

const onLoad = () => {
    loadConfig.loading.value = false;
};
const loadingFailed = err => {
    loadConfig.loading.value = false;
    errorTips(t('error.pdfError'));
};

// 获取流程详情
const process = ref(null);
const getProcess = snowflakeId => {
    api.contractProcess(snowflakeId).then(res => {
        if (!res || res.code != 1) {
            return;
        }
        process.value = res.data;
    });
};
</script>

<style scoped lang="scss">
.pdfEmbed {
    height: 100%;
    width: 55%;
    overflow-y: auto;
    overflow-x: hidden;
    margin-left: 50px;
}

.right {
    height: 100%;
    overflow-y: auto;
    width: 30%;
    padding: 20px;
}
</style>
